/*
 * 系统菜单
 */
DC.front.SysToolBar = function(config) {
	/*DC.front.SysToolBar.superclass.constructor.call(this, Ext.apply({
		id: 'sys_toolBar',
		height: 28,
		margins: '0 0 0 0',
		region: 'north',
		border : true,
		//style : 'background-color:#d3e5fb !important',
		items: [{
			id: 'sys_file',
			text: 'File...',
			width : 50,
			menu: new DC.front.menu.FileMenu()
		}, '-', {
			id: 'sys_refresh',
			text: 'Refresh',
			width : 50
		}, {
			id: 'sys_delete',
			text: 'Delete...',
			width : 50,
			disabled : true,
			listeners : {
				click : function() {
					DC.action.SysAction.deleteNode(DC.obj.explorer_treePanel.getSelectionModel().getSelectedNode());
				}
			}
		}, {
			id: 'sys_download',
			text: 'Download',
			width : 50
		}, '-', {
			id: 'sys_build_path',
			text: 'Build Path',
			width : 50
		}, '-', {
			id: 'sys_project',
			text: 'Project',
			width : 50,
			menu: new DC.front.menu.Project()
		}, '-']
    }, config || {}));*/
	DC.front.SysToolBar.superclass.constructor.call(this, Ext.apply({
		id: 'sys_toolBar',
		height: 28,
		margins: '0 0 0 0',
		region: 'north',
		border : true,
		items: ['-', {
			id: 'sys_toolbar_new',
			iconCls : 'new_icon',
			tooltip : 'New',
			menu: new DC.front.menu.NewMenu()
		}, '-', {
			id: 'sys_toolbar_download',
			iconCls : 'download_icon',
			tooltip : 'Download',
			disabled : true,
			width : 25,
			listeners : {
				click : function() {
					DC.action.SysAction.downloadZipFile(DC.url.DOWNLOAD_ZIPFILE);
				}
			}
		}, {
			id: 'sys_toolbar_build',
			iconCls : 'build_icon',
			tooltip : 'Build',
			disabled : true,
			width : 25,
			listeners : {
				click : function() {
					DC.action.SysAction.buildProject();
				}
			}
		}, '-', {
			id: 'sys_toolbar_cut',
			iconCls : 'cut_icon',
			tooltip : 'Cut',
			width : 25
		},{
			id : 'sys_toolbar_copy',
			iconCls : 'copy_icon',
			tooltip : 'Copy',
			width : 25
		}, {
			id : 'sys_toolbar_paste',
			iconCls : 'paste_icon',
			tooltip : 'Paste',
			width : 25
		}, {
			id: 'sys_toolbar_delete',
			iconCls : 'delete_icon',
			tooltip : 'Delete',
			disabled : true,
			width : 25,
			listeners : {
				click : function() {
					DC.action.SysAction.deleteNode(DC.obj.explorer_treePanel.getSelectionModel().getSelectedNode());
				}
			}
		}, {
			id : 'sys_toolbar_refresh',
			iconCls : 'refresh_icon',
			tooltip : 'ReLoad Project Tree',
			width : 25,
			listeners : {
				click : function() {
					DC.obj.explorer_treePanel.reloadData();
				}
			}
		}]
    }, config || {}));
};

Ext.extend(DC.front.SysToolBar, Ext.Toolbar, {
	
});

// 文件菜单的下级菜单 
DC.front.menu.NewMenu = function(config) {
	
	DC.front.menu.NewMenu.superclass.constructor.call(this, Ext.apply({
		id : 'new_menu',
		allowOtherMenus : false, //不允许同时显示多个菜单
		width : 200,
		items : [{
			id : 'sys_toolbar_new_project',
			text : 'New Project',
			iconCls : 'new_project_icon',
			listeners : {
				click : function() {
					new DC.front.win.NewProjectWin().show();
				}
			}
		}, '-', {
			id : 'sys_toolbar_new_class',
			text : 'New Class',
			iconCls : 'class_obj_icon',
			disabled : true,
			listeners : {
				click : function() {
					var selectedNode = DC.obj.explorer_treePanel.getSelectionModel().getSelectedNode();
					var path = "";
					if (selectedNode && !selectedNode.isLeaf()) {
						var array = selectedNode.getPath().split('/');
						var srcNodeText = DC.obj.explorer_treePanel.getNodeById(array[3]).attributes.text;
						if (srcNodeText == "src") {
							var project_id = array[2];
							var project_name = DC.obj.explorer_treePanel.getNodeById(array[2]).attributes.text;
							for (var i = 4, len = array.length; i < len; i++) {
								path = path + DC.obj.explorer_treePanel.getNodeById(array[i]).attributes.text + ".";
							}
							path = path.substring(0, path.length - 1);
							console.log(path);
							console.log(project_id);
							console.log(project_name);
							new DC.front.win.CreateClassWin({
								project_id : project_id,
								project_name : project_name,
								package_name : path
							}).show();
						}
					}
				}
			}
		}, {
			id : 'sys_toolbar_new_file',
			text : 'New File',
			iconCls : 'new_file_icon',
			disabled : true,
			listeners : {
				click : function() {
					new  DC.front.win.NewFileWin({
						type : 'file'
					}).show();
				}
			}
		}, {
			id : 'sys_toolbar_new_folder',
			text : 'New Folder',
			iconCls : 'folder_add_icon',
			disabled : true,
			listeners : {
				click : function() {
					new  DC.front.win.NewFileWin({
						type : 'folder'
					}).show();
				}
			}
		}]
	}, config ||{}));
};

Ext.extend(DC.front.menu.NewMenu, Ext.menu.Menu, {
	
});